/**
* Copyright (C) 2020 Xilinx, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may
* not use this file except in compliance with the License. A copy of the
* License is located at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

#define MAX_DIM 16

// Tripcount identifiers
const int c_size = MAX_DIM;

extern "C" {
void madd(int *a, int *b, int *c, const int dim) {

  int matA[MAX_DIM * MAX_DIM];
  int matB[MAX_DIM * MAX_DIM];

// Auto-pipeline is going to apply pipeline to these loops
madd_readA:
  for (int i = 0; i < dim * dim; ++i) {
#pragma HLS LOOP_TRIPCOUNT min = c_size*c_size max = c_size*c_size
    matA[i] = a[i];
  }

madd_readB:
  for (int i = 0; i < dim * dim; ++i) {
#pragma HLS LOOP_TRIPCOUNT min = c_size*c_size max = c_size*c_size
    matB[i] = b[i];
  }

madd_writeC:
  for (int i = 0; i < dim * dim; ++i) {
#pragma HLS LOOP_TRIPCOUNT min = c_size*c_size max = c_size*c_size
    c[i] = matA[i] + matB[i];
  }
}
}
